var zoom = 0;

$(function(){
	includeMyAlert();
	checkCity();
})
/**
 * 左侧栏收缩
 */
function zoom_left(){
	if(zoom == 0){
		$("#sidebar").children("ul").hide();
		$("#sidebar").css("width", "20px");
		$("#sidebarzoom").css("margin-left", "20px");
		$("#sidebarzoom").children("img").attr("src",domain+"/views/images/arrow_right.png");
		$("#content").css("margin-left", "60px");
		zoom = 1;
	} else {
		$("#sidebar").children("ul").show();
		$("#sidebar").css("width", "240px");
		$("#sidebarzoom").css("margin-left", "240px");
		$("#sidebarzoom").children("img").attr("src",domain+"/views/images/arrow_left.png");
		$("#content").css("margin-left", "280px");
		zoom = 0;
	}
}

function changeCurrent(){
	//alert(curPageName);
	$("#menu_"+curPageName).parent("li").addClass("current");
	$("#menu_"+curPageName).parent("li").parent("ul").parent("li").addClass("current");
	$("#menu_"+curPageName).parent("li").parent("ul").show();
}

function logout(){
	myConfirm("确定退出登录？", function(){
		$("#myConfirmDialog").hide();		//关闭提示窗口
	    $("#myAlertMask").hide();			//关闭遮罩层
	    
	    location.href=domain+"/admin-login/logout";
	})
}

/**
 * 保存城市信息到cookie
 * */
function checkCity(){
	var city = $.cookie("cityId",{path: domain});
	if(city){
		$("#select_city option[value="+city+"]").attr("selected",true);
	}else{
		$.cookie("cityId",$("#select_city option:first").val(),{path: domain});
		$.cookie("cityTitle",$("#select_city option:first").text(),{path: domain});
	}
	$("#select_city").bind('change',function(){
		$.cookie("cityId",this.value,{path: domain});
		$.cookie("cityTitle",$(this).find(":checked").text(),{path: domain});
		$("#SearchForm").submit();
	});
//格式化时间
Date.prototype.format = function(format){
	var o = {
	"M+" : this.getMonth()+1, 
	"d+" : this.getDate(), 
	"h+" : this.getHours(),
	"m+" : this.getMinutes(),
	"s+" : this.getSeconds(),
	"q+" : Math.floor((this.getMonth()+3)/3),
	"S" : this.getMilliseconds()
	}
	if(/(y+)/.test(format)) {
		format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
	}
	for(var k in o) {
		if(new RegExp("("+ k +")").test(format)) {
			format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
		}
	}
	return format;
}
}